home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77644_sh_datetime.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  30.2 KB  |  919 lines

  1. <%@ Language=VBScript   %>
  2. <%    Option Explicit     %>
  3.  
  4. <%    '==================================================
  5.     ' Microsoft Server Appliance
  6.     '
  7.     ' Sets server appliance date and time
  8.     '
  9.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  10.     '================================================== %>
  11.  
  12.  
  13.     <!-- #include virtual="/admin/inc_framework.asp" -->
  14.     <!-- #include file="loc_datetime.asp" -->
  15.  
  16. <%  
  17.  
  18.     '-------------------------------------------------------------------------
  19.     ' Global Variables
  20.     '-------------------------------------------------------------------------
  21.      Dim page
  22.  
  23.     Dim SOURCE_FILE
  24.     Const ENABLE_TRACING = FALSE
  25.     SOURCE_FILE = SA_GetScriptFileName()
  26.     
  27.     '-------------------------------------------------------------------------
  28.     ' Global Form Variables
  29.     '-------------------------------------------------------------------------
  30.  
  31.     ' Form values
  32.     Dim g_sDateID
  33.     Dim g_sTimeID
  34.  
  35.     Dim g_sDay
  36.     Dim g_sMonth
  37.     Dim g_sYear
  38.     Dim g_sHour
  39.     Dim g_sMinute
  40.     Dim g_sSecond
  41.     Dim g_sTimeZone
  42.     Dim g_sEnableDaylight
  43.     Dim g_sWasChanged
  44.  
  45.     Dim mstrCHelperPROGID
  46.     Dim mstrTimeFormat
  47.     Dim mstrTimeFormatPathName
  48.     Dim mstrTimeFormatValue
  49.     
  50.     
  51.     '======================================================
  52.     ' Entry point
  53.     '======================================================
  54.     
  55.     '
  56.     ' Create a Property Page
  57.     Call SA_CreatePage( L_TASKTITLE_TEXT, "images/datetime_icon.GIF", PT_PROPERTY, page )
  58.     
  59.     '
  60.     ' Serve the page
  61.     Call SA_ShowPage( page )
  62.     
  63.  
  64.  
  65.     '======================================================
  66.     ' Web Framework Event Handlers
  67.     '======================================================
  68.     
  69.     '---------------------------------------------------------------------
  70.     ' Function:    OnInitPage
  71.     '
  72.     ' Synopsis:    Called to signal first time processing for this page. Use this method
  73.     '            to do first time initialization tasks. 
  74.     '
  75.     ' Returns:    TRUE to indicate initialization was successful. FALSE to indicate
  76.     '            errors. Returning FALSE will cause the page to be abandoned.
  77.     '
  78.     '---------------------------------------------------------------------
  79.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  80.         If ( ENABLE_TRACING ) Then
  81.             Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  82.         End If
  83.  
  84.         Call GetAutoAdjustInfo()    
  85.         g_sTimeZone = GetTimeZone()
  86.         g_sDateID =  FormatDateTime(date, vbShortDate)
  87.         g_sTimeID =  FormatDateTime(time, vbLongTime)
  88.     
  89.         OnInitPage = TRUE
  90.     End Function
  91.  
  92.  
  93.     
  94.     '---------------------------------------------------------------------
  95.     ' Function:    OnServePropertyPage
  96.     '
  97.     ' Synopsis:    Called when the page needs to be served. Use this method to
  98.     '            serve content.
  99.     '
  100.     ' Returns:    TRUE to indicate not problems occured. FALSE to indicate errors.
  101.     '            Returning FALSE will cause the page to be abandoned.
  102.     '
  103.     '---------------------------------------------------------------------
  104.     Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  105.         OnServePropertyPage = TRUE
  106.         If ( ENABLE_TRACING ) Then
  107.             Call SA_TraceOut(SOURCE_FILE, "OnServePropertyPage")
  108.         End If
  109.  
  110.         ServePage
  111.  
  112.     End Function
  113.         
  114.  
  115. '----------------------------------------------------------------------------
  116. '
  117. ' Function : ServePage
  118. '
  119. ' Synopsis : serve the property page
  120. '
  121. ' Arguments: None
  122. '
  123. ' Returns  : None
  124. '
  125. '----------------------------------------------------------------------------
  126.  
  127. Sub ServePage
  128.  
  129.     Dim sTempTimeZone    
  130.     Dim sEnableDaylightAttr
  131.  
  132.     If ( g_sEnableDaylight = "Y" ) Then
  133.         sEnableDaylightAttr = ""
  134.     Else
  135.         sEnableDaylightAttr = " DISABLED "
  136.     End If
  137.     %>
  138.     <SCRIPT LANGUAGE=JavaScript>
  139.         //To set Date and Time from the Client
  140.         function PresetTimeZone()
  141.         {
  142.             timezone = "<% =g_sTimeZone %>";
  143.                         
  144.             ZoneOpt = document.frmTask.ZoneList.options;
  145.             
  146.             for (ind = 0; ind < ZoneOpt.length; ind++)
  147.             {
  148.                 if (ZoneOpt[ind].value == timezone + "#1")
  149.                 {
  150.                     document.frmTask.ZoneList.selectedIndex = ind;    
  151.                     
  152.                     EnableDaylightChecked();
  153.                     if (document.frmTask.EnableDaylight.value == "Y")    
  154.                     {    
  155.                         document.frmTask.EnableDaylightCheck.checked= true;    
  156.                     }
  157.                     else
  158.                     {    
  159.                         document.frmTask.EnableDaylightCheck.checked= false;
  160.                     }
  161.                     return;
  162.                 }
  163.                 else if (ZoneOpt[ind].value == timezone + "#0")
  164.                 {
  165.                     document.frmTask.ZoneList.selectedIndex = ind;
  166.  
  167.                     DisableDaylightChecked();
  168.                     
  169.                 }
  170.             }
  171.             
  172.         }
  173.  
  174.         function EnableDaylightChecked()
  175.         {
  176.             SetDaylightControl(false);
  177.         }
  178.         
  179.         function DisableDaylightChecked()
  180.         {
  181.             SetDaylightControl(true);
  182.         }
  183.         
  184.         function SetDaylightControl(bEnabled)
  185.         {
  186.             var oDaylightChecked = document.getElementById("EnableDaylightCheck");
  187.             if ( oDaylightChecked == null )
  188.             {
  189.                 if ( SA_IsDebugEnabled() )
  190.                 {
  191.                     alert("document.getElementById(EnableDaylightCheck) returned null");
  192.                 }
  193.             }
  194.             else
  195.             {
  196.                 oDaylightChecked.disabled = bEnabled;
  197.                 oDaylightChecked.checked = !bEnabled;
  198.             }
  199.  
  200.             var oDaylightText = document.getElementById("EnableDaylightText");
  201.             if ( oDaylightText == null )
  202.             {
  203.                 if ( SA_IsDebugEnabled() )
  204.                 {
  205.                     alert("document.getElementById(EnableDaylightText) returned null");
  206.                 }
  207.             }
  208.             else
  209.             {
  210.                 if ( bEnabled )
  211.                 {
  212.                     oDaylightText.className = "TasksBodyDisabled";
  213.                 }
  214.                 else
  215.                 {
  216.                     oDaylightText.className = "TasksBody";
  217.                 }
  218.             }
  219.         }
  220.         
  221.         //Function is called on change of the zone selected from browser
  222.         function ZoneChanged()
  223.         {
  224.             StopRefresh();
  225.             ZoneInfo = document.frmTask.ZoneList.options[document.frmTask.ZoneList.selectedIndex].value.split("#");
  226.             if (ZoneInfo[1] == "0")
  227.             {
  228.                 DisableDaylightChecked();
  229.             }
  230.             else
  231.             {
  232.                 EnableDaylightChecked();
  233.             }
  234.         }
  235.             
  236.     </SCRIPT>    
  237.  
  238.     <script language="JavaScript">    
  239.         var TimeoutID;
  240.         
  241.         function Refresh()
  242.         {
  243.             document.frmTask.submit();
  244.         }
  245.                 
  246.         function StopRefresh()
  247.         {
  248.             window.clearTimeout(TimeoutID);
  249.             document.frmTask.WasChanged.value = "Y"
  250.         }
  251.  
  252.         function Init() 
  253.         {            
  254.             PresetTimeZone();
  255.     <% If ("" = GetErrMsg) Then
  256.         response.write "TimeoutID = window.setTimeout('Refresh()', 60000);"
  257.     End If %>            
  258.         }
  259.                 
  260.         //Function Validates the inputs of the page before submit.
  261.         function ValidatePage() 
  262.         { 
  263.  
  264.                 return true;
  265.         }
  266.         
  267.  
  268.          function SetData()
  269.         {
  270.             // set data to hidden form values
  271.             ZoneInfo=document.frmTask.ZoneList.options[document.frmTask.ZoneList.selectedIndex].value.split("#");
  272.             document.frmTask.StandardName.value = ZoneInfo[0];
  273.         
  274.             if (document.frmTask.EnableDaylightCheck.checked)
  275.             {
  276.                 document.frmTask.EnableDaylight.value="Y";
  277.             }
  278.             else
  279.             {
  280.                 document.frmTask.EnableDaylight.value="N";
  281.             }    
  282.             
  283.          }     
  284.         
  285.     </script>
  286.     
  287.  
  288. <input name="StandardName" type="hidden" value="<% =g_sTimeZone %>">
  289. <input name="EnableDaylight" type="hidden" value="<% =g_sEnableDaylight %>">
  290. <input name="WasChanged" type="hidden" value="<% =g_sWasChanged %>">
  291.  
  292. <TABLE   BORDER=0 CELLSPACING=0 CELLPADDING=0 xclass="TasksBody">
  293.  
  294. <tr>
  295. <td NOWRAP class="TasksBody"><%=L_DATE%></td>
  296. <td class="TasksBody">
  297. <input class="FormField" type="text" name="DateID" id=DateID size=20 maxlength=40 value='<%=g_sDateID%>' onkeypress="StopRefresh()">
  298. </td>
  299. </tr>
  300.  
  301. <tr>
  302. <td NOWRAP class="TasksBody"><p  id=PareID_Time><%=L_TIME%></p></td>
  303. <td class="TasksBody">
  304. <input class="FormField" type="text" name="TimeID" id=TimeID size=20 maxlength=20 value='<%=g_sTimeID%>' onkeypress="StopRefresh()">
  305. </td>
  306. </tr>
  307.  
  308.  
  309. <tr>
  310. <td NOWRAP class="TasksBody"><p  id=PareID_TimeZone><%=L_TIMEZONE%></p></td>
  311. <td class="TasksBody">
  312.  
  313.  
  314. <% RenderTimezoneList %>
  315.  
  316.  
  317.  
  318. </td>
  319. </tr>
  320. <tr><td id=P1ID_1 > </td></tr>
  321. </table>
  322. <table cellpadding="0" cellspacing="0 border="0">
  323. <tr>
  324.     <td class="TasksBody"><INPUT TYPE='checkbox' <%=sEnableDaylightAttr%> class=FormField name='EnableDaylightCheck' id='EnableDaylightCheck' onclick='StopRefresh()'></td>
  325.     <td class="TasksBody" id="EnableDaylightText"><%=L_AUTOMATICALLY_TEXT%></td>
  326. </tr>
  327. </table>
  328. <p id=PareID_Note><strong><%=L_NOTE_LEFT_TEXT%></strong>
  329. <BR id=PareID_IndepnedenceNote><%=L_NOTE_DESCRIPTION_TEXT%></p>
  330.  
  331. <%    
  332.  End Sub 
  333.  
  334.  
  335.     '---------------------------------------------------------------------
  336.     ' Function:    OnPostBackPage
  337.     '
  338.     ' Synopsis:    Called to signal that the page has been posted-back. A post-back
  339.     '            occurs in tabbed property pages and wizards as the user navigates
  340.     '            through pages. It is differentiated from a Submit or Close operation
  341.     '            in that the user is still working with the page.
  342.     '
  343.     '            The PostBack event should be used to save the state of page.
  344.     '
  345.     ' Returns:    TRUE to indicate initialization was successful. FALSE to indicate
  346.     '            errors. Returning FALSE will cause the page to be abandoned.
  347.     '
  348.     '---------------------------------------------------------------------
  349.     Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  350.         OnPostBackPage = TRUE
  351.         If ( ENABLE_TRACING ) Then
  352.             Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  353.         End If
  354.  
  355.         g_sDateID = Request.Form("DateID")
  356.         g_sTimeID = Request.Form("TimeID")
  357.         g_sTimeZone = Request.Form("StandardName")
  358.         g_sEnableDaylight = Request.Form("EnableDaylight")
  359.         g_sWasChanged = Request.Form("WasChanged")
  360.  
  361.         If ("Y" <> g_sWasChanged) Then
  362.             g_sTimeZone = GetTimeZone()
  363.             g_sDateID =  FormatDateTime(date, vbShortDate)
  364.             g_sTimeID =  FormatDateTime(time, vbLongTime)
  365.             Call GetAutoAdjustInfo()    
  366.         End If
  367.  
  368.     End Function
  369.  
  370.  
  371.     '---------------------------------------------------------------------
  372.     ' Function:    OnSubmitPage
  373.     '
  374.     ' Synopsis:    Called when the page has been submitted for processing. Use
  375.     '            this method to process the submit request.
  376.     '
  377.     ' Returns:    TRUE if the submit was successful, FALSE to indicate error(s).
  378.     '            Returning FALSE will cause the page to be served again using
  379.     '            a call to OnServePropertyPage.
  380.     '
  381.     '---------------------------------------------------------------------
  382.     Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  383.  
  384.         Const CONST_SETSYSTIMEPRIVILEGE = "SeSystemTimePrivilege"
  385.  
  386.         on error resume next
  387.         Err.Clear
  388.  
  389.         Dim objSAHelper
  390.         Dim bModifiedPrivilege
  391.  
  392.         bModifiedPrivilege = FALSE
  393.         'Create SAHelper object
  394.         Set objSAHelper = Server.CreateObject("ServerAppliance.SAHelper")    
  395.  
  396.         if err.number <> 0 Then
  397.             SA_TraceOut "Create object failed for SAHelper object", err.description
  398.         else
  399.             'enable set system time privilege
  400.             bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SETSYSTIMEPRIVILEGE, TRUE)
  401.             if err.number <> 0 Then
  402.                 SA_TraceOut "Enable privilege failed", err.description
  403.                 exit function
  404.             end if
  405.         end if
  406.  
  407.         If ( ENABLE_TRACING ) Then
  408.             Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  409.         End If
  410.          OnSubmitPage = SetServerDate
  411.  
  412.         if ( bModifiedPrivilege ) then
  413.             'revert back to disabled state
  414.             bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SETSYSTIMEPRIVILEGE, FALSE)
  415.             if err.number <> 0 Then
  416.                 SA_TraceOut "Disable privilege failed", err.description
  417.                 exit function
  418.             end if
  419.         end if
  420.  
  421.         set objSAHelper = Nothing
  422.  
  423.  
  424.      End Function
  425.  
  426.  
  427.     '---------------------------------------------------------------------
  428.     ' Function:    OnClosePage
  429.     '
  430.     ' Synopsis:    Called when the page is about to be closed. Use this method
  431.     '            to perform clean-up processing.
  432.     '
  433.     ' Returns:    TRUE to allow close, FALSE to prevent close. Returning FALSE
  434.     '            will result in a call to OnServePropertyPage.
  435.     '
  436.     '---------------------------------------------------------------------
  437.     Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  438.          OnClosePage = TRUE
  439.         If ( ENABLE_TRACING ) Then
  440.             Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  441.         End If
  442.     End Function
  443.  
  444.  
  445. '----------------------------------------------------------------------------
  446. '
  447. ' Function : SetServerDate
  448. '
  449. ' Synopsis : function to set server date and time
  450. '
  451. ' Arguments: None
  452. '
  453. ' Returns  : None
  454. '
  455. '----------------------------------------------------------------------------
  456.  
  457. Function SetServerDate()
  458.  
  459. Dim sErrorMessage
  460.  
  461.     SetServerDate = False
  462.  
  463.     If IsDate(g_sDateID) Then
  464.         g_sDay = CStr(Day(g_sDateID))
  465.         g_sMonth = CStr(Month(g_sDateID))
  466.         g_sYear = CStr(Year(g_sDateID))
  467.         If ( ENABLE_TRACING ) Then
  468.             Call SA_TraceOut(SOURCE_FILE, "SetServerDate Date (D/M/Y):"+g_sDay+"/"+g_sMonth+"/"+g_sYear)
  469.         End If
  470.  
  471.         If (1991 > Year(g_sDateID)) Or (2037 < Year(g_sDateID)) Then
  472.             Call SA_TraceOut(SOURCE_FILE, "SetServerDate Date not valid:"+g_sDateID+" year:"+CStr(Year(g_sDateID)))
  473.             sErrorMessage = GetLocString("datetimemsg.dll","&H400100B3", Array(g_sDay, MonthName(g_sMonth), g_sYear))
  474.                 Call SetErrMsg(sErrorMessage)
  475.             SetServerDate = False 
  476.             exit function
  477.         End If
  478.     Else
  479.             SetErrMsg L_INVALIDDATE_ERRORMESSAGE
  480.         SetServerDate = False 
  481.         exit function
  482.     End If    
  483.  
  484.     If IsDate(g_sTimeID) Then
  485.         g_sHour = CStr(Hour(g_sTimeID))
  486.         g_sMinute = CStr(Minute(g_sTimeID))
  487.         g_sSecond = CStr(Second(g_sTimeID))
  488.         If ( ENABLE_TRACING ) Then
  489.             Call SA_TraceOut(SOURCE_FILE, "SetServerDate Time:"+g_sHour+"/"+g_sMinute+"/"+g_sSecond)
  490.         End If
  491.     Else
  492.             SetErrMsg L_INVALIDTIME_ERRORMESSAGE 
  493.         SetServerDate = False 
  494.         exit function
  495.     End If    
  496.  
  497.     If SetTimeZone = True Then
  498.         If SetDateTime = True Then
  499.             SetServerDate = True
  500.         End If
  501.     End If
  502. End Function
  503.  
  504.  
  505.  
  506. '----------------------------------------------------------------------------
  507. '
  508. ' Function : GetTimeZone
  509. '
  510. ' Synopsis : gets the Time Zone
  511. '
  512. ' Arguments: None
  513. '
  514. ' Returns  : None
  515. '
  516. '----------------------------------------------------------------------------
  517.  
  518. Function GetTimeZone()
  519.     on error resume next
  520.     Err.Clear
  521.     
  522.     Dim Locator
  523.     Dim Service
  524.     Dim TimeZone
  525.     Dim Entries
  526.     Dim entry
  527.     Dim StandardName
  528.  
  529.     
  530.     Set Service = GetWMIConnection("")
  531.     Set TimeZone = Service.Get("Win32_TimeZone")
  532.     Set Entries = TimeZone.Instances_    
  533.     If Err.number<>0 then 
  534.             SetErrMsg L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  535.             GetTimeZone=""
  536.             Exit Function
  537.     End if
  538.     For each entry in Entries
  539.         StandardName = entry.StandardName    'There should be only one entry
  540.     Next
  541.     GetTimeZone = StandardName
  542.     
  543.     Set Service = nothing
  544.     Set TimeZone = nothing
  545.     
  546. End Function
  547.  
  548.  
  549. '----------------------------------------------------------------------------
  550. '
  551. ' Function : SetTimeZone
  552. '
  553. ' Synopsis : sets the Time Zone
  554. '
  555. ' Arguments: None
  556. '
  557. ' Returns  : None
  558. '
  559. '----------------------------------------------------------------------------
  560. Function SetTimeZone 
  561.     on error resume next
  562.     Err.Clear
  563.     
  564.     Dim objTCtx
  565.     Dim Error
  566.  
  567.     
  568.     Error = ExecuteTask("SetTimeZone", objTCtx)
  569.     if Error <> 0 then
  570.         SetErrMsg L_INVALIDTIMEZONE_ERRORMESSAGE 
  571.         SetTimeZone = False
  572.     Else
  573.         SetTimeZone = True
  574.     End if
  575.     
  576.     set objTCtx = Nothing
  577. End Function
  578.  
  579.  
  580. '----------------------------------------------------------------------------
  581. '
  582. ' Function : SetDateTime
  583. '
  584. ' Synopsis : sets the date and time on the server
  585. '
  586. ' Arguments: None
  587. '
  588. ' Returns  : None
  589. '
  590. '----------------------------------------------------------------------------
  591. Function SetDateTime
  592.     on error resume next
  593.     Err.Clear
  594.     
  595.     Dim objTCtx
  596.     Dim Error
  597.  
  598.     'We are calculating values on the server, so we need to put them into
  599.     'the TaskContext object
  600.  
  601.     Set objTCtx = CreateObject("Taskctx.TaskContext")
  602.     If Err.Number <> 0 Then
  603.             SetErrMsg L_TASKCTX_OBJECT_CREATION_FAIL_ERRORMESSAGE
  604.         SetDateTime = False
  605.         Exit Function
  606.     End If
  607.  
  608.     objTCtx.SetParameter "Day", g_sDay
  609.     objTCtx.SetParameter "Month", g_sMonth
  610.     objTCtx.SetParameter "Year", g_sYear
  611.     objTCtx.SetParameter "Hour", g_sHour
  612.     objTCtx.SetParameter "Minute", g_sMinute
  613.     objTCtx.SetParameter "Second", g_sSecond
  614.  
  615.     Error = ExecuteTask("SetDateTime", objTCtx)
  616.     if Error <> 0 then
  617.             SetErrMsg L_INVALIDDATETIME_ERRORMESSAGE 
  618.         SetDateTime = False
  619.     End if
  620.     
  621.     Err.Clear
  622.     
  623.     set objTCtx = Nothing
  624.     SetDateTime = True
  625. End Function
  626.  
  627.  
  628.  
  629. '----------------------------------------------------------------------------
  630. '
  631. ' Function : GetAutoAdjustInfo()
  632. '
  633. ' Synopsis : function to Get Auto Adjust of Daylight time set up
  634. '
  635. ' Arguments: None
  636. '
  637. ' Returns  : None
  638. '
  639. '----------------------------------------------------------------------------
  640. Function GetAutoAdjustInfo()
  641.     on error resume next
  642.     Err.Clear
  643.     
  644.     Dim Providers
  645.     Dim Provider
  646.  
  647.     Set Providers = GetObject("winmgmts:" & SA_GetWMIConnectionAttributes() & "!root/cimv2").InstancesOf ("ProviderDateTimeAdjust")
  648.     If Err.number<>0 then 
  649.             SetErrMsg L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE
  650.             GetAutoAdjustInfo=False
  651.             Exit Function
  652.     End if
  653.     g_sEnableDaylight = "Y"
  654.     For each Provider in Providers    ' Must be only one
  655.         If IsEmpty(Provider.DisableAutoDaylightTimeSet) Or Provider.DisableAutoDaylightTimeSet <> 1  Then        
  656.             g_sEnableDaylight = "Y"
  657.         Else 
  658.             g_sEnableDaylight = "N"
  659.         End If
  660.     next    
  661.  
  662.     Set Providers = nothing
  663.     
  664. End Function
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671. '----------------------------------------------------------------------------
  672. '
  673. ' Function : RenderTimezoneList()
  674. '
  675. ' Synopsis : function render the timezone list
  676. '
  677. ' Arguments: None
  678. '
  679. ' Returns  : None
  680. '
  681. '----------------------------------------------------------------------------
  682. Function RenderTimezoneList()
  683.  
  684.     on error resume next
  685.     Err.Clear
  686.  
  687.     const CONST_LIST_SIZE = 74
  688.  
  689.     Dim objRegService
  690.     Dim i, j
  691.     Dim arrTimezone (74, 2)
  692.  
  693.     set objRegService = RegConnection()
  694.     
  695.     'VBScript arrays are zero-based, to make the it's compatible with L_TIMEZONES_TEXT
  696.     'we start it from 1 to 74, arrTimezone(0, i) is ignored
  697.     
  698.     '
  699.     'Init the timezone array
  700.     '
  701.     'Set the option text
  702.     for i = 1 to CONST_LIST_SIZE
  703.         arrTimezone(i, 2) = L_TIMEZONES_TEXT(i)
  704.     Next
  705.  
  706.     'Set the option Ids, which are used by the test team
  707.     arrTimezone(1,  0) = "PareID_Enewetak"    
  708.     arrTimezone(2,  0) = "PareID_MidwayIland"
  709.     arrTimezone(3,  0) = "PareID_Hawaii"                            
  710.     arrTimezone(4,  0) = "PareID_Alaska"        
  711.     arrTimezone(5,  0) = "PareID_Pacific"                                
  712.     arrTimezone(6,  0) = "PareID_Arizona"    
  713.     arrTimezone(7,  0) = "PareID_Mountain"    
  714.     arrTimezone(8,  0) = "PareID_America"    
  715.     arrTimezone(9,  0) = "PareID_CentralUS"
  716.     arrTimezone(10, 0) = "PareID_Mexico"    
  717.     arrTimezone(11, 0) = "PareID_Saskatchewan"    
  718.     arrTimezone(12, 0) = "PareID_Bogota"        
  719.     arrTimezone(13, 0) = "PareID_EasternUS"    
  720.     arrTimezone(14, 0) = "PareID_Indiana"    
  721.     arrTimezone(15, 0) = "PareID_Atlantic"
  722.     arrTimezone(16, 0) = "PareID_Caracas"    
  723.     arrTimezone(17, 0) = "PareID_PacificStandard" 
  724.     arrTimezone(18, 0) = "PareID_Newfoundland" 
  725.     arrTimezone(19, 0) = "PareID_Brasilia" 
  726.     arrTimezone(20, 0) = "PareID_BuenosAires" 
  727.     arrTimezone(21, 0) = "PareID_Greenland" 
  728.     arrTimezone(22, 0) = "PareID_MidAtlantic" 
  729.     arrTimezone(23, 0) = "PareID_Azores"     
  730.     arrTimezone(24, 0) = "PareID_Cape" 
  731.     arrTimezone(25, 0) = "PareID_Casablanca"     
  732.     arrTimezone(26, 0) = "PareID_Greenwich" 
  733.     arrTimezone(27, 0) = "PareID_Amsterdam" 
  734.     arrTimezone(28, 0) = "PareID_Belgrade" 
  735.     arrTimezone(29, 0) = "PareID_Brussels" 
  736.     arrTimezone(30, 0) = "PareID_Sarajevo" 
  737.     arrTimezone(31, 0) = "PareID_CenAfrica" 
  738.     arrTimezone(32, 0) = "PareID_Athens"     
  739.     arrTimezone(33, 0) = "PareID_Bucharest" 
  740.     arrTimezone(34, 0) = "PareID_Cairo" 
  741.     arrTimezone(35, 0) = "PareID_Harare"         
  742.     arrTimezone(36, 0) = "PareID_Helsinki"     
  743.     arrTimezone(37, 0) = "PareID_Israel"        
  744.     arrTimezone(38, 0) = "PareID_Baghdad"
  745.     arrTimezone(39, 0) = "PareID_Kuwait"        
  746.     arrTimezone(40, 0) = "PareID_Moscow"        
  747.     arrTimezone(41, 0) = "PareID_Nairobi"
  748.     arrTimezone(42, 0) = "PareID_Tehran"        
  749.     arrTimezone(43, 0) = "PareID_AbuDhabi"
  750.     arrTimezone(44, 0) = "PareID_Baku"
  751.     arrTimezone(45, 0) = "PareID_Kabul"
  752.     arrTimezone(46, 0) = "PareID_Ekaterinburg"
  753.     arrTimezone(47, 0) = "PareID_Islamabad"    
  754.     arrTimezone(48, 0) = "PareID_Bombay"    
  755.     arrTimezone(49, 0) = "PareID_Nepal"    
  756.     arrTimezone(50, 0) = "PareID_Novosibirsk"
  757.     arrTimezone(51, 0) = "PareID_Almaty"    
  758.     arrTimezone(52, 0) = "PareID_Colombo"
  759.     arrTimezone(53, 0) = "PareID_Myanmar"
  760.     arrTimezone(54, 0) = "PareID_Bangkok"
  761.     arrTimezone(55, 0) = "PareID_Krasnoyarsk"
  762.     arrTimezone(56, 0) = "PareID_Beijing"
  763.     arrTimezone(57, 0) = "PareID_Irkutsk"
  764.     arrTimezone(58, 0) = "PareID_Singapore"
  765.     arrTimezone(59, 0) = "PareID_Perth"
  766.     arrTimezone(60, 0) = "PareID_Taipei"
  767.     arrTimezone(61, 0) = "PareID_Osaka"                                                
  768.     arrTimezone(62, 0) = "PareID_Seoul"                                                
  769.     arrTimezone(63, 0) = "PareID_Yakutsk"
  770.     arrTimezone(64, 0) = "PareID_Adelaide"                                                
  771.     arrTimezone(65, 0) = "PareID_Darwin"                                                
  772.     arrTimezone(66, 0) = "PareID_Brisbane"                                                
  773.     arrTimezone(67, 0) = "PareID_Canberra"                                                
  774.     arrTimezone(68, 0) = "PareID_Guam"                                                
  775.     arrTimezone(69, 0) = "PareID_Hobart"                                                
  776.     arrTimezone(70, 0) = "PareID_Vladivostok"                                                
  777.     arrTimezone(71, 0) = "PareID_Magadan"                                                
  778.     arrTimezone(72, 0) = "PareID_Auckland"                                                
  779.     arrTimezone(73, 0) = "PareID_Fiji"                                                
  780.     arrTimezone(74, 0) = "PareID_Nuku"                                                
  781.  
  782.     'Set the Option values based on the registry value
  783.     arrTimezone(1,  1) = GetTimezoneValueFromRegistry(objRegService, "Dateline Standard Time")            & "#0"
  784.     arrTimezone(2,  1) = GetTimezoneValueFromRegistry(objRegService, "Samoa Standard Time")                & "#0"
  785.     arrTimezone(3,  1) = GetTimezoneValueFromRegistry(objRegService, "Hawaiian Standard Time")            & "#0"
  786.     arrTimezone(4,  1) = GetTimezoneValueFromRegistry(objRegService, "Alaskan Standard Time")                & "#1"
  787.     arrTimezone(5,  1) = GetTimezoneValueFromRegistry(objRegService, "Pacific Standard Time")                & "#1"
  788.     arrTimezone(6,  1) = GetTimezoneValueFromRegistry(objRegService, "US Mountain Standard Time")            & "#0"
  789.     arrTimezone(7,  1) = GetTimezoneValueFromRegistry(objRegService, "Mountain Standard Time")            & "#1"
  790.     arrTimezone(8,  1) = GetTimezoneValueFromRegistry(objRegService, "Central America Standard Time")        & "#0"
  791.     arrTimezone(9,  1) = GetTimezoneValueFromRegistry(objRegService, "Central Standard Time")                & "#1"
  792.     arrTimezone(10, 1) = GetTimezoneValueFromRegistry(objRegService, "Mexico Standard Time")                & "#1"
  793.     arrTimezone(11, 1) = GetTimezoneValueFromRegistry(objRegService, "Canada Central Standard Time")        & "#0"
  794.     arrTimezone(12, 1) = GetTimezoneValueFromRegistry(objRegService, "SA Pacific Standard Time")            & "#0"
  795.     arrTimezone(13, 1) = GetTimezoneValueFromRegistry(objRegService, "Eastern Standard Time")                & "#1"
  796.     arrTimezone(14, 1) = GetTimezoneValueFromRegistry(objRegService, "US Eastern Standard Time")            & "#0"
  797.     arrTimezone(15, 1) = GetTimezoneValueFromRegistry(objRegService, "Atlantic Standard Time")            & "#1"
  798.     arrTimezone(16, 1) = GetTimezoneValueFromRegistry(objRegService, "SA Western Standard Time")            & "#0"
  799.     arrTimezone(17, 1) = GetTimezoneValueFromRegistry(objRegService, "Pacific SA Standard Time")            & "#1"
  800.     arrTimezone(18, 1) = GetTimezoneValueFromRegistry(objRegService, "Newfoundland Standard Time")        & "#1"
  801.     arrTimezone(19, 1) = GetTimezoneValueFromRegistry(objRegService, "E. South America Standard Time")    & "#1"
  802.     arrTimezone(20, 1) = GetTimezoneValueFromRegistry(objRegService, "SA Eastern Standard Time")            & "#0"
  803.     arrTimezone(21, 1) = GetTimezoneValueFromRegistry(objRegService, "Greenland Standard Time")            & "#1"
  804.     arrTimezone(22, 1) = GetTimezoneValueFromRegistry(objRegService, "Mid-Atlantic Standard Time")        & "#1"
  805.     arrTimezone(23, 1) = GetTimezoneValueFromRegistry(objRegService, "Azores Standard Time")                & "#1"
  806.     arrTimezone(24, 1) = GetTimezoneValueFromRegistry(objRegService, "Cape Verde Standard Time")            & "#0"
  807.     arrTimezone(25, 1) = GetTimezoneValueFromRegistry(objRegService, "Greenwich Standard Time")            & "#0"
  808.     arrTimezone(26, 1) = GetTimezoneValueFromRegistry(objRegService, "GMT Standard Time")                    & "#1"
  809.     arrTimezone(27, 1) = GetTimezoneValueFromRegistry(objRegService, "W. Europe Standard Time")            & "#1"
  810.     arrTimezone(28, 1) = GetTimezoneValueFromRegistry(objRegService, "Central Europe Standard Time")        & "#1"
  811.     arrTimezone(29, 1) = GetTimezoneValueFromRegistry(objRegService, "Romance Standard Time")                & "#1"
  812.     arrTimezone(30, 1) = GetTimezoneValueFromRegistry(objRegService, "Central European Standard Time")    & "#1"
  813.     arrTimezone(31, 1) = GetTimezoneValueFromRegistry(objRegService, "W. Central Africa Standard Time")    & "#0"
  814.     arrTimezone(32, 1) = GetTimezoneValueFromRegistry(objRegService, "GTB Standard Time")                    & "#1"
  815.     arrTimezone(33, 1) = GetTimezoneValueFromRegistry(objRegService, "E. Europe Standard Time")            & "#1"
  816.     arrTimezone(34, 1) = GetTimezoneValueFromRegistry(objRegService, "Egypt Standard Time")                & "#1"
  817.     arrTimezone(35, 1) = GetTimezoneValueFromRegistry(objRegService, "South Africa Standard Time")        & "#0"
  818.     arrTimezone(36, 1) = GetTimezoneValueFromRegistry(objRegService, "FLE Standard Time")                    & "#1"
  819.     arrTimezone(37, 1) = GetTimezoneValueFromRegistry(objRegService, "Israel Standard Time")            & "#0"
  820.     arrTimezone(38, 1) = GetTimezoneValueFromRegistry(objRegService, "Arabic Standard Time")                & "#1"
  821.     arrTimezone(39, 1) = GetTimezoneValueFromRegistry(objRegService, "Arab Standard Time")                & "#0"
  822.     arrTimezone(40, 1) = GetTimezoneValueFromRegistry(objRegService, "Russian Standard Time")                & "#1"
  823.     arrTimezone(41, 1) = GetTimezoneValueFromRegistry(objRegService, "E. Africa Standard Time")            & "#0"
  824.     arrTimezone(42, 1) = GetTimezoneValueFromRegistry(objRegService, "Iran Standard Time")                & "#1"
  825.     arrTimezone(43, 1) = GetTimezoneValueFromRegistry(objRegService, "Arabian Standard Time")                & "#0"
  826.     arrTimezone(44, 1) = GetTimezoneValueFromRegistry(objRegService, "Caucasus Standard Time")            & "#1"
  827.     arrTimezone(45, 1) = GetTimezoneValueFromRegistry(objRegService, "Afghanistan Standard Time")            & "#0"
  828.     arrTimezone(46, 1) = GetTimezoneValueFromRegistry(objRegService, "Ekaterinburg Standard Time")        & "#1"
  829.     arrTimezone(47, 1) = GetTimezoneValueFromRegistry(objRegService, "West Asia Standard Time")            & "#0"
  830.     arrTimezone(48, 1) = GetTimezoneValueFromRegistry(objRegService, "India Standard Time")                & "#0"
  831.     arrTimezone(49, 1) = GetTimezoneValueFromRegistry(objRegService, "Nepal Standard Time")                & "#0"
  832.     arrTimezone(50, 1) = GetTimezoneValueFromRegistry(objRegService, "N. Central Asia Standard Time")        & "#1"
  833.     arrTimezone(51, 1) = GetTimezoneValueFromRegistry(objRegService, "Central Asia Standard Time")        & "#0"
  834.     arrTimezone(52, 1) = GetTimezoneValueFromRegistry(objRegService, "Sri Lanka Standard Time")            & "#0"
  835.     arrTimezone(53, 1) = GetTimezoneValueFromRegistry(objRegService, "Myanmar Standard Time")                & "#0"
  836.     arrTimezone(54, 1) = GetTimezoneValueFromRegistry(objRegService, "SE Asia Standard Time")                & "#0"
  837.     arrTimezone(55, 1) = GetTimezoneValueFromRegistry(objRegService, "North Asia Standard Time")            & "#1"
  838.     arrTimezone(56, 1) = GetTimezoneValueFromRegistry(objRegService, "China Standard Time")                & "#0"
  839.     arrTimezone(57, 1) = GetTimezoneValueFromRegistry(objRegService, "North Asia East Standard Time")        & "#1"
  840.     arrTimezone(58, 1) = GetTimezoneValueFromRegistry(objRegService, "Singapore Standard Time")        & "#0"
  841.     arrTimezone(59, 1) = GetTimezoneValueFromRegistry(objRegService, "W. Australia Standard Time")        & "#0"
  842.     arrTimezone(60, 1) = GetTimezoneValueFromRegistry(objRegService, "Taipei Standard Time")                & "#0"
  843.     arrTimezone(61, 1) = GetTimezoneValueFromRegistry(objRegService, "Tokyo Standard Time")                & "#0"
  844.     arrTimezone(62, 1) = GetTimezoneValueFromRegistry(objRegService, "Korea Standard Time")                & "#0"
  845.     arrTimezone(63, 1) = GetTimezoneValueFromRegistry(objRegService, "Yakutsk Standard Time")                & "#1"
  846.     arrTimezone(64, 1) = GetTimezoneValueFromRegistry(objRegService, "Cen. Australia Standard Time")        & "#1"
  847.     arrTimezone(65, 1) = GetTimezoneValueFromRegistry(objRegService, "AUS Central Standard Time")            & "#0"
  848.     arrTimezone(66, 1) = GetTimezoneValueFromRegistry(objRegService, "E. Australia Standard Time")        & "#0"
  849.     arrTimezone(67, 1) = GetTimezoneValueFromRegistry(objRegService, "AUS Eastern Standard Time")            & "#1"
  850.     arrTimezone(68, 1) = GetTimezoneValueFromRegistry(objRegService, "West Pacific Standard Time")        & "#0"
  851.     arrTimezone(69, 1) = GetTimezoneValueFromRegistry(objRegService, "Tasmania Standard Time")            & "#1"
  852.     arrTimezone(70, 1) = GetTimezoneValueFromRegistry(objRegService, "Vladivostok Standard Time")            & "#1"
  853.     arrTimezone(71, 1) = GetTimezoneValueFromRegistry(objRegService, "Central Pacific Standard Time")        & "#0"
  854.     arrTimezone(72, 1) = GetTimezoneValueFromRegistry(objRegService, "New Zealand Standard Time")            & "#1"
  855.     arrTimezone(73, 1) = GetTimezoneValueFromRegistry(objRegService, "Fiji Standard Time")                & "#0"
  856.     arrTimezone(74, 1) = GetTimezoneValueFromRegistry(objRegService, "Tonga Standard Time")                & "#0"
  857.  
  858.     '
  859.     'Render the select list
  860.     '
  861.     %>
  862.     <select class="FormField" name="ZoneList" ID="ZoneList" size="1" onchange="ZoneChanged()">
  863.     <%
  864.        for i = 1 to CONST_LIST_SIZE 
  865.     %>    
  866.  
  867.         <option id=<%=arrTimezone(i,0)%> value="<%=arrTimezone(i,1)%>"        
  868.         <% 
  869.         ' Check to see if the option is the selected one
  870.         If (1 = InStr(arrTimezone(i,1), g_sTimeZone)) Then %> 
  871.             selected 
  872.         <% End If %> >
  873.                 
  874.         <%=arrTimezone(i,2)%>
  875.         
  876.         </option>        
  877.     <%
  878.         next
  879.     %>    
  880.     </select>
  881.     <%
  882.     
  883.     set objRegService = nothing
  884.  
  885. End Function
  886.  
  887.  
  888. '----------------------------------------------------------------------------
  889. '
  890. ' Function : GetTimezoneValueFromRegistry
  891. '
  892. ' Synopsis : Get the timezone value from the registry key
  893. '
  894. ' Arguments: In-objRegService : registry service
  895. '            In-strKey : English name of the timezone
  896. '
  897. ' Returns  : registry key value of the timezone
  898. '
  899. '----------------------------------------------------------------------------
  900. Function GetTimezoneValueFromRegistry(objRegService, strName)
  901.  
  902.         on error resume next
  903.         Err.Clear
  904.         
  905.         CONST CONST_TIMEZONEPATH = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"
  906.         CONST CONST_STRING = 2
  907.         CONST CONST_KEYNAME = "Std"
  908.       
  909.         GetTimezoneValueFromRegistry = GetRegKeyValue(objRegService, CONST_TIMEZONEPATH & strName, CONST_KEYNAME, CONST_STRING)
  910.          
  911.         If Err.number <> 0 Then
  912.             GetTimezoneValueFromRegistry = ""
  913.             Exit Function
  914.         end if
  915.          
  916. End Function
  917.  
  918. %>
  919.